package com.bluemobi.framework.listener;

import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.context.ApplicationContext;
import org.springframework.web.context.support.WebApplicationContextUtils;

/**
 * 系统启动监听器
 */
public class SystemInitListener implements ServletContextListener {

	private static Log logger = LogFactory.getLog(SystemInitListener.class);

	@Override
	public void contextInitialized(ServletContextEvent servletContextEvent) {
		ApplicationContext applicationContext = WebApplicationContextUtils
				.getWebApplicationContext(servletContextEvent.getServletContext());
		ApplicationContextHolder applicationContextHolder = new ApplicationContextHolder();
		applicationContextHolder.setApplicationContext(applicationContext);
		logger.info("********************************************");
		logger.info("系统启动成功.....");
	}

	@Override
	public void contextDestroyed(ServletContextEvent servletContextEvent) {
		logger.info("********************************************");
		logger.info("系统关闭成功.....");
	}
}
